<?php
/**
 * Created by PhpStorm.
 * User: zwc
 * Date: 2018/11/18
 * Time: 23:21
 */

namespace addons\hlapp\service;


use addons\hlapp\controller\FileCache;
use addons\hlapp\model\CacheEnum;
use addons\hlapp\model\HlappProjectType;

//种类和类型service
class TypeStageService
{
    //项目类型
    public $typeModel;

    public function __construct()
    {
        $this->typeModel = new HlappProjectType();
    }

    // 获取类型列表
    public function getProjectTypes(){
        return $this->typeModel->getTypeList();
    }

    /**
     * 从缓存获取部门信息
     * @return mixed
     * @throws \think\exception\DbException
     */
    public static function getParts(){
        $part_cache_name = CacheEnum::PART_CACHE_NAME;
        $cache = new FileCache();
        $part_info = $cache->get($part_cache_name);
        if (!$part_info){
            \Log::INFO("更新部门缓存");
            $part_info = HlappPart::all();
            $cache->set($part_cache_name,$part_info);
        }
        return $part_info;
    }

}